package cn.kgc.mvc.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: mosin
 * @version: v1.0  2022/7/6
 */
@WebServlet("/user")
public class HelloServlet extends BaseServlet {

    protected void login(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //设置编码格式 处理中文乱码
        req.setCharacterEncoding("utf-8");
        // 获取请求参数   数据类型的转换
        String username = req.getParameter("username");
        String password = req.getParameter("password");


        //  调用业务层 进行具体的业务处理

        System.out.println("业务层调用成功!" + username + ":" + password);

        //  根据业务层返回的处理结果  响应不同的结果给浏览器  页面(视图)  转发  重定向   json数据  fastJson   user  map

        resp.sendRedirect(req.getContextPath() + "/index.jsp");

    }

    protected void register(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {


        System.out.println("注册业务被调用");
    }


}
